package com.hs.controller;


import com.hs.entity.dto.MessageDTO;
import com.hs.entity.pojo.Message;
import com.hs.service.MessageService;
import com.hs.utils.ResultResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hs
 * @since 2023-08-05
 */
@RestController
@RequestMapping("/message")
@Api(tags = "消息")
public class MessageController {

    @Resource
    private MessageService messageService;

    @PostMapping("/saveMessage")
    @ApiOperation("保存消息到redis中")
    public ResultResponse<?> saveMessage(@RequestBody MessageDTO messageDTO){
        return messageService.saveMessage(messageDTO);
    }

    @GetMapping("/getMessages")
    @ApiOperation("根据dialogueId查询消息")
    public ResultResponse<List<Message>> getMessageByDialogueId(@RequestParam Integer dialogueId){
        return messageService.getMessageByDialogueId(dialogueId);
    }
}

